$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL +'sys/logger/list',
        datatype: "json",
        colModel: [
            { label: '日志id', name: 'id', index: "id", width: 45, key: true,hidden:true },
            { label: '用户姓名', name: 'realName',width: 20},
            { label: '操作', name: 'operation',width: 30},
            { label: '调用方法', name: 'method', width: 80},
            { label: '参数', name: 'params', width: 80},
            { label: 'IP地址', name: 'ip', width: 30},
            { label: '时间', name: 'createTime',width: 30}
        ],
        viewrecords: true,
        height: 385,
        rowNum: 10,
        rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 45,
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.result",
            page: "page.pageNo",
            total: "page.totalPages",
            records: "page.total"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
});

var vm = new Vue({
    el:'#logger',
    data:{
        q:{
            realName: null
        },
        showList: true,
        info:{
            id:null,
            reason:null
        }

    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function () {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{'realName': vm.q.realName},
                page:page
            }).trigger("reloadGrid");
        }
    }
});